package com.dw.dwdzcommerce.view.mainContent.mainActionBar;

import com.dw.dwdzcommerce.R;
import com.dw.dwdzcommerce.base.fragment.BaseFragment;
import com.dw.dwdzcommerce.view.mainContent.mainActionBar.PopupType.OnItemClickListener;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class MainContentActionBarFragment extends BaseFragment {
	View mTypes;
	View mSearch;

	@Override
	public int getViewLayout() {
		return R.layout.fragment_actionbar_main_content;
	}

	@Override
	protected void initView(View view) {
		mTypes = view.findViewById(R.id.fragment_actionbar_main_back_tv);
		mSearch = view.findViewById(R.id.fragment_actionbar_main_search_tv);
	}

	@Override
	protected void bindView(View view) {
		mTypes.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				PopupType p = new PopupType();
				p.init(getActivity());
				p.setData(new String[] { "衣", "食", "住", "用", "行" });
				p.setmOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(View view, int pos,int arg0) {
//						Toast.makeText(getActivity(), view.getTag().toString() + " pos=" + pos, Toast.LENGTH_LONG)
//								.show();
						if(mListener!=null){
							mListener.onTypes(view.getTag().toString(), pos);
						}
					}
				});
				p.show(v); 
			}
		});
		mSearch.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if(mListener!=null){
					mListener.onSearch(v);
				}
//				Toast.makeText(getContext(), "search", Toast.LENGTH_LONG).show();
			}
		});
	}

	@Override
	public void onViewGreate(View view, Bundle savedInstanceState) {
	}
	
	private OnMainContentActionBarClickListener mListener;
	public void setmListener(OnMainContentActionBarClickListener mListener) {
		this.mListener = mListener;
	}
	public interface OnMainContentActionBarClickListener{
		void onSearch(View view);
		void onTypes(String type,int pos);
	}

}
